from typing import *
from math import inf

class Solution:
    def minIncrementOperations(self, nums: List[int], k: int)-> int:
        n = len(nums)
        f = [inf] * (n + 1)
        f[0] = 0
        for i in range(1,n+ 1):
            for j in range(max(0, i-3),i):
                f[i] = min(f[i] ,f[j])
            f[i] += max(k - nums[i - 1] , 0)
        return min(f[-1],f[-2],f[-3])

s = Solution()
print(s.minIncrementOperations([13,34,0,13,9,19],82))